package cn.edu.jxau.test;

import java.util.Arrays;

import cn.edu.jxau.util.ArrayList;
import cn.edu.jxau.util.List;

public class Main {

    public static void main(String[] args) {

        int[] arr = new int[] { 12, 43, 65, 79, 34, 65, 23, 89, 54 };
        sort(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void sort(int[] arr) {
        sort(arr, 0, arr.length - 1);
    }

    private static void sort(int[] arr, int low, int high) {

        if (high <= low) {
            return;
        }
        int min = arr[low];
        int minIndex = low;
        for (int i = low + 1; i <= high; i++) {
            if (arr[i] < min) {
                min = arr[i];
                minIndex = i;
            }
        }
        int temp = arr[low];
        arr[low] = arr[minIndex];
        arr[minIndex] = temp;
        sort(arr, low + 1, high);
    }
}